package com.dameng.jianyouquan.utils;

import android.content.Context;
import android.content.SharedPreferences;

public class SpUtils {



    public static void setValue(Context context,String key,String value){
        SharedPreferences sharedPreferences = context.getSharedPreferences("user", Context.MODE_PRIVATE); //私有数据
        SharedPreferences.Editor editor = sharedPreferences.edit();//获取编辑器
        editor.putString(key, value);
        editor.apply();//提交修改

    }



    public static void setValueInt(Context context,String key,int value){
        SharedPreferences sharedPreferences = context.getSharedPreferences("user", Context.MODE_PRIVATE); //私有数据
        SharedPreferences.Editor editor = sharedPreferences.edit();//获取编辑器
        editor.putInt(key, value);
        editor.apply();//提交修改

    }


    public static String getValue(Context context,String key){
        SharedPreferences sharedPreferences = context.getSharedPreferences("user", Context.MODE_PRIVATE); //私有数据
        return sharedPreferences.getString(key, "");

    }



    public static int getValueInt(Context context,String key){
        SharedPreferences sharedPreferences = context.getSharedPreferences("user", Context.MODE_PRIVATE); //私有数据
        return sharedPreferences.getInt(key, 0);

    }





}
